function [likelihood_contribution]=likelihood_contrib(parameter,ability_metric,LowCost_Ability,HighCost_Ability,V_l,V_h,outcome,tpORtp3h,Cpm25,parameter_fixed)
% Compared to likelihood_obj, outputs Nx1 vector of likelihood contributions

%N=size(LowCost_Ability,1);

% Parameters that are fixed
%cutoff_tp =parameter_fixed(1);
%cutoff_pm =parameter_fixed(2);
%delta_0   =parameter_fixed(3);
%cutoff2_tp=parameter_fixed(4);    % Two bins for each environmental condition
%cutoff2_pm=parameter_fixed(5);

% Parameters that are estimated 
k        =parameter(1);
%delta_tp =parameter(3);
%delta_pm =parameter(4);
%delta2_tp=parameter(5);           % Two bins for each environmental condition
%delta2_pm=parameter(6);
                
% Two bins for each environmental condition
%delta = repmat(delta_0,N,1) + delta_tp*(tpORtp3h>cutoff_tp).*(tpORtp3h<=cutoff2_tp) + delta2_tp*(tpORtp3h>cutoff2_tp)...
%                            + delta_pm*(Cpm25>cutoff_pm).*(Cpm25<=cutoff2_pm)       + delta2_pm*(Cpm25>cutoff2_pm);


% Marginal cost (mc) function:
% inputs: ability metric, cost parameter, LowCost_Ability, HighCost_Ability
% outputs: c_l, c_h
[c_l,c_h]=mc(ability_metric,parameter,LowCost_Ability,HighCost_Ability);

% transition_prob_oneshot:
% inputs: c_l, c_h, V_l, V_h, k
% outputs: p_l_winoneshot=p_l_win3, p_h_winoneshot=p_h_win3
[p_lwin3,p_llose3]=transition_prob_oneshot(c_l,c_h,V_l,V_h,k);

% transition_prob_stage2:
% inputs: c_l, c_h,  V_l, V_h, temperature, PM2.5, k, parameters of the delta function, calls on transition_prob_oneshot
% outputs: Continuation values (in stage 3) conditional on stage-2 outcome (and stage-1 history), stage-2 transition probabilities  
[~,~,~,~,~,~,~,~,p_lwin2_lwon1,p_llose2_lwon1,p_lwin2_llost1,p_llose2_llost1]=transition_prob_stage2(parameter,tpORtp3h,Cpm25,parameter_fixed,c_l,c_h,V_l,V_h);

% transition_prob_stage1:
% inputs: c_l, c_h, V_l, V_h, temperature, PM2.5, k, parameters of the delta function, calls on transition_prob_stage2
% outputs: Continuation values (in stage 2) conditional on stage-1 outcome, stage-1 transition probabilities   
[~,~,~,~,p_lwin1,p_llose1]=transition_prob_stage1(parameter,tpORtp3h,Cpm25,parameter_fixed,c_l,c_h,V_l,V_h);



% Compute probabilities for each match outcome (this can be sped up if necessary subsequently; e.g., for simulated likelihood)
prob_ll =p_lwin1 .*  p_lwin2_lwon1;
prob_lhl=p_lwin1 .* p_llose2_lwon1.* p_lwin3;
prob_lhh=p_lwin1 .* p_llose2_lwon1.*p_llose3;
prob_hll=p_llose1.* p_lwin2_llost1.* p_lwin3;
prob_hlh=p_llose1.* p_lwin2_llost1.*p_llose3;
prob_hh =p_llose1.*p_llose2_llost1;
prob=[prob_ll prob_lhl prob_lhh prob_hll prob_hlh prob_hh];
likelihood_contribution=sum(prob.*outcome,2);


end